package util;

import org.springframework.validation.BindingResult;
import winkyle.woodenfish.android.exception.ParamException;


/**
 * @author winkyle
 * @date 2018/06/22
 * @description 表单验证结果处理类
 */

public class BindingResultUtil {

	/**
	 * @description 若表单验证结果有错则抛出参数异常
	 * @param bindingResult表单验证结果
	 * @return
	 */
	public static void verify(BindingResult bindingResult) {
		if(bindingResult.hasErrors()) {
			throw new ParamException(
					bindingResult.getFieldError().getDefaultMessage());
		}
	}
}
